package com.wjjun.test.ui

import android.util.Log
import android.view.View
import androidx.databinding.ViewDataBinding
import com.wjjun.base.ui.activity.BaseListActivity
import com.wjjun.base.ui.viewmodel.BaseItemViewModel
import com.wjjun.base.ui.viewmodel.BaseViewModel
import com.wjjun.app.R
import com.wjjun.test.ui.itemviewmodel.Test2ItemViewModel
import com.wjjun.test.ui.itemviewmodel.TestDragItemViewModel
import com.wjjun.test.ui.viewmodel.TestDragListViewModel
import com.wjjun.test.ui.itemviewmodel.TestItemViewModel
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.delay
import kotlin.collections.ArrayList
import kotlin.math.log

/**
 * 测试拖动列表界面
 * author : wangjunjun
 * date   : 2022/6/29
 * desc   :
 */
@AndroidEntryPoint
class TestDragListActivity : BaseListActivity<TestDragListViewModel, ViewDataBinding>() {

    override fun initContent() {
        setTitle("测试拖动列表界面")
        setRefreshEnable(true)
    }

    override fun initParams() {
        mRecycleViewHelper.setDragEnable(true)
    }

    override suspend fun fetchData() {
        delay(1000)
        refreshData()
    }

    override fun onClick(view: View) {

    }

    override suspend fun fetchData(pageNum: Int, pageSize: Int, useCache: Boolean, param: Any?) {
        val list = ArrayList<BaseItemViewModel<*>>()
        for( i in 0..10){
            list.add(TestDragItemViewModel(i.toString()))
        }
        setData(list, pageNum)
    }

    override fun onItemClick(view: View, itemViewModel: BaseViewModel) {
    }
}